import type {
  TOrder,
  consultPayApi,
  consultPayReq,
  depAllApi,
  patientConsultOrderApi,
  patientConsultOrderPreApi,
  patientConsultOrderPreReq,
  uploadPostApi
} from '@/types/consult'
import type { patientMylistApiItem } from '@/types/user'
import request from '@/utils/request'

// 查询科室
export const depAll = () => request<depAllApi>('/dep/all')

// 上传图片
export const uploadPost = (file: File) => {
  const t = new FormData()
  t.append('file', file)
  return request<uploadPostApi>('/upload', 'post', t)
}

// 预支付信息获取
export const patientConsultOrderPre = (data: patientConsultOrderPreReq) =>
  request<patientConsultOrderPreApi>('/patient/consult/order/pre', 'get', data)

// 查询患者详情
export const patientInfo = (id: string) => request<patientMylistApiItem>(`/patient/info/${id}`)

// 创建支付订单
export const patientConsultOrder = (data: TOrder) =>
  request<patientConsultOrderApi>('/patient/consult/order', 'post', data)

// 支付
export const consultPay = (data: consultPayReq) =>
  request<consultPayApi>('/patient/consult/pay', 'post', data)
